<template>
	<view>
		<view class="sjld r">
			<h2>历史访问</h2>
			<view class="lsjl" v-for="(item,index) in historyData"  :key="index">
				<view class="button r">{{item}}</view>
			</view>
		</view>
		 <view class="orderbox">
			<view class="box-warp">
				<view class="type-item-spec">
					<view class="" v-for="(item,index) in items"  :key="index"  :class="{btna:count == index}"@click="change(index)">
						<view class="type-name">{{item}}</view>
					</view>
				</view>
			</view>
	
			<!-- 省级-->
			<view class="box-warp end-cont " :class="{dis:btnnum == 0}">
				<view class="" v-for="(item,index) in sjData"  :key="index">
					<view class="button" @click="sjClick(item,1)">{{item.name}}</view>
				</view>
			</view>
			<!-- 市州级 -->
			<view class="box-warp end-cont " :class="{dis:btnnum == 1}">
				<view class="" v-for="(item,index) in szData"  :key="index">
					<view class="button" @click="sjClick(item,2)">{{item.name}}</view>
				</view>
			</view>
			<!-- 县市级 -->
			<view class="box-warp end-cont " :class="{dis:btnnum == 2}">
				<view class="" v-for="(item,index) in xsData"  :key="index">
					<view class="button" @click="sjClick(item,3)">{{item.name}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				items: ["省级", "市州级","县市级"],
				btnnum: 0,
				count: "",
				sjData:[
					{
						name:'湖南',
						list:[
							{name:'全部'},
							{
								'name':'长沙市',
								'list':[
									{name:'全部'},
									{'name':'天心区',},
									{'name':'雨花区',},
									{'name':'芙蓉区',},
									{'name':'岳麓区',},
								]
							},
							{
								'name':'株洲市',
								'list':[
									{name:'全部'},
									{'name':'株天心区',},
									{'name':'株雨花区',},
									{'name':'株芙蓉区',},
									{'name':'株岳麓区',},
								]
							}
						]
					},
				],
				szData:[],
				xsData:[],
				historyData:[]
			}
		},
		methods:{
			sjClick(data,num){
				uni.setNavigationBarTitle({
					title:data.name
				})
				if(this.historyData.length == 0){
					this.historyData.push(data.name)
				}else{
					if(this.historyData.indexOf(data.name) == -1){
						this.historyData.push(data.name)
					}
				}
				let chooseName=data.name;
				if(num==1){
					console.log("省级："+ data.name);
				}else if(num==2){
					console.log("市州级："+ data.name);
					chooseName = data.name;
					if(data.name=="全部"){
						debugger;
						chooseName = this.sjData.list.list[0].name;
						uni.navigateTo({
							url:"./index?dingwei="+chooseName
						})
					}
				}else{
					console.log("县级："+ data.name);
				}
				
				if(data.name !== '全部'){
					this.btnnum++
					this.count++
					if(num == 1){
						this.szData = data.list
					}else{
						this.xsData = data.list
					}
				}
				
			},
			change(e) {
				this.count = e
				this.btnnum = e;
			},
		},
		
	}
</script>

<style scoped>
	@import url("index.css");
</style>
